package com.itheima.health.controller;


import com.itheima.health.common.MessageConst;
import com.itheima.health.entity.Result;
import com.itheima.health.service.SmsService;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping("/mobile/validateCode")
@RestController
@Slf4j
public class ValidateCodeController {


    @DubboReference
    SmsService smsService;
    /**
     * @Author: JASON
     * @Date: 14:55 2021/1/10
     * @Parms [type, telephone]
     * @ReturnType: void
     * @Description: 发送短信验证码
     */
    @PostMapping("/send")
    public Result send(String type, String telephone){
        log.info("[验证码-发送]type:{},telephone:{}", type, telephone);
        //rpc调用发送验证码
        smsService.sendValidateCode(type, telephone);
        return new Result(true, MessageConst.SEND_VALIDATECODE_SUCCESS);
    }
}
